<template>
	<view>
		<!-- <view class="title">行为</view>
		<tui-tags ref="behaviorRef" shape="circleLeft" size="small" :tags="behavior"></tui-tags> -->
		<!-- <view class="title">恐惧对象</view>
		<tui-tags ref="fearRef" shape="circleLeft" size="small" :tags="fear"></tui-tags> -->
		<view class="title">身体状态</view>
		<tui-tags ref="conditionRef" shape="circleLeft" size="small" :tags="condition"></tui-tags>
		<view class="title">情绪状态</view>
		<tui-tags ref="emotionRef" shape="circleLeft" size="small" :tags="emotion"></tui-tags>
	</view>
</template>

<script>
	import tuiTags from '@/components/tag/tags'
	export default {
		components: {
			tuiTags
		},
		props: {
			yonghuBiaoQian: {
				type: Array,
				default: () => []
			}
		},
		data() {
			return {
				behavior: [],
				fear: [],
				condition: [],
				emotion: []
			}
		},
		created() {

		},
		async mounted() {
			await this.init();
			//this.$refs.behaviorRef.concatTags(this.behavior);
			this.$refs.conditionRef.concatTags(this.condition);
			this.$refs.emotionRef.concatTags(this.emotion);
		},
		methods: {
			concatYonghuBiaoQian(array) {
				this.yonghuBiaoQian = this.yonghuBiaoQian.concat(array);
			},
			async init() {
				const data = {
					type: 'yhbq'
				}
				const that = this;
				this.yonghuBiaoQian = this.yonghuBiaoQian || []
				let res = await this.$api.findGlobalcodelist(data);
				// .then(res => {})
				console.log(res);
				let list = res.data;
				list.forEach(item => {
					item.fontSize = 10;
					if (that.$tools.arrayTool.includes(that.yonghuBiaoQian, item.id)) {
						item.check = true;
					} else {
						item.check = false;

					}
				})
				this.behavior = list.filter(item => {
					return item.remarks == "行为标签"
				})
				this.fear = list.filter(item => {
					return item.remarks == "恐惧对象标签"
				})
				this.condition = list.filter(item => {
					return item.remarks == "身体状态标签"
				})
				this.emotion = list.filter(item => {
					return item.remarks == "情绪状态"
				})
				console.log(this.behavior, this.condition, this.emotion);

			},
			getClickTags() {
				let data = {
					yonghuBiaoQian: []
				}
				//data.yonghuBiaoQian = data.yonghuBiaoQian.concat(this.$refs.behaviorRef.getCode());
				// data.yonghuBiaoQian = data.yonghuBiaoQian.concat(this.$refs.fearRef.getCode());
				data.yonghuBiaoQian = data.yonghuBiaoQian.concat(this.$refs.conditionRef.getCode());
				data.yonghuBiaoQian = data.yonghuBiaoQian.concat(this.$refs.emotionRef.getCode());

				return data.yonghuBiaoQian;
			}
		}
	}
</script>

<style scoped>
	.title {
		padding: 30upx 0;
		font-size: 32upx;
		color: #333;
		font-weight: bold;
	}
</style>
